/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.dtgenerator.api.mgrInterface;

import com.inspur.edp.bef.api.be.IBEService;
import com.inspur.edp.bef.dtgenerator.DotNetToJavaStringHelper;
import com.inspur.edp.bef.dtgenerator.api.ApiHelper;
import com.inspur.edp.bef.dtgenerator.api.BefApiGeneratorContext;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrAllInterface.MgrAllInterfaceGenerator;
import com.inspur.edp.cef.generator.overall.Utils;

public class BEMgrAllInterfaceGenerator extends MgrAllInterfaceGenerator {
  private BefApiGeneratorContext apiGenContext;

  public BEMgrAllInterfaceGenerator(BefApiGeneratorContext apiGenContext) {
    super(apiGenContext);
    this.apiGenContext = apiGenContext;
  }

  @Override
  protected String getName() {
    return ApiHelper.getBEMgrAllInterfaceClassName(apiGenContext.getCommonModel());
  }

  @Override
  protected java.util.ArrayList<com.inspur.edp.caf.generator.baseInfo.TypeInfo>
      addParentInterfaces() {
    java.util.ArrayList<com.inspur.edp.caf.generator.baseInfo.TypeInfo> rez =
        super.addParentInterfaces();
    if (rez == null) {
      rez = new java.util.ArrayList<com.inspur.edp.caf.generator.baseInfo.TypeInfo>();
    }
    if (!DotNetToJavaStringHelper.isNullOrEmpty(
        apiGenContext.getBeGenCtx().getBE().getDependentEntityId())) {
      // TODO: java版临时注释 deb暂不支持
      throw new UnsupportedOperationException();
      //      // wj-dbe已改
      //      if (apiGenContext.getBeGenCtx().getIsParentBEInSameProj()) {
      //        return null;
      //      }
      //      String parentClassName = getParentClassName();
      //      return new java.util.ArrayList<com.inspur.edp.caf.generator.baseInfo.TypeInfo>(
      //          java.util.Arrays.asList(
      //              new com.inspur.edp.caf.generator.baseInfo.TypeInfo[] {
      //                apiGenContext.getBeGenCtx().getParentBEAssembly().getType(parentClassName)
      //              }));
    } else {
      rez.add(Utils.createTypeInfo(IBEService.class));
    }
    return rez;
  }

  // TODO: java版临时注释 deb暂不支持
  //  @Override
  //  protected java.util.ArrayList<String> addGeneratedParentInterfaces() {
//    var rez =
  //        ((super.addGeneratedParentInterfaces()) != null)
  //            ? super.addGeneratedParentInterfaces()
  //            : new java.util.ArrayList<String>();
  //
  //    if
  // (!DotNetToJavaStringHelper.isNullOrEmpty(apiGenContext.getBeGenCtx().getBE().DependentEntityId)
  //        && apiGenContext.getBeGenCtx().getIsParentBEInSameProj()) {
  //      rez.Add(GetParentClassName());
  //    }
  //    return rez;
  //  }
  //
  //  private String getParentClassName() {
  //    return String.format(
  //        "%1$s.%2$s",
  //        apiGenContext.getParentNamespace(),
  //        ApiHelper.GetBEMgrAllInterfaceClassName(apiGenContext.getBeGenCtx().getParentBE()));
  //  }
}
